package wakeonlan;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Client {

	public Client() {
		
	}
	
	private boolean isBusy() {
    	try {  
            Process p = Runtime.getRuntime().exec("who");
            BufferedReader in = new BufferedReader(  
                                new InputStreamReader(p.getInputStream()));
            if(in.readLine() == null) {  
                	return false;
            }  
        } catch (IOException e) {}
        return true;
    }
    
    private void shutdown() {
    	try {
    		if(!isBusy())
    			Runtime.getRuntime().exec("shutdown -h 0");
		} catch (IOException e) {
			e.printStackTrace();
		}
    }
}
